home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Unix / Defaults / Source / Defaults.m < prev    next >
Text File  |  1995-06-12  |  4KB  |  127 lines

  1. /*--------------------------------------------------------------------*/
  2. /*                                                                    */
  3. /*                         DISCLAIMER NOTICE                          */
  4. /*                                                                    */
  5. /* This document and/or  portions of the material  and data furnished */
  6. /* herewith, was developed under sponsorship of the U.S.  Government. */
  7. /* Neither the  U.S.  nor  the U.S.D.O.E.,   nor the  Leland Stanford */
  8. /* Junior  University,  nor  their employees,   nor their  respective */
  9. /* contractors,   subcontractors,   or their  employees,   makes  any */
  10. /* warranty,   express  or  implied,  or  assumes  any  liability  or */
  11. /* responsibility for  accuracy,  completeness  or usefulness  of any */
  12. /* information,   apparatus,   product  or   process  disclosed,   or */
  13. /* represents that its use will  not infringe privately-owned rights. */
  14. /* Mention of any product, its manufacturer,  or suppliers shall not, */
  15. /* nor is it intended to, imply approval, disapproval, or fitness for */
  16. /* any particular  use.   The U.S.  and  the University at  all times */
  17. /* retain  the right  to use  and  disseminate same  for any  purpose */
  18. /* whatsoever.                                                        */
  19. /*                                                                    */
  20. /*--------------------------------------------------------------------*/
  21. /*                                                                    */
  22. /* Copyright (C)  1989  The Board of Trustees of  The Leland Stanford */
  23. /* Junior University.  All Rights Reserved.                           */
  24. /*                                                                    */
  25. /*--------------------------------------------------------------------*/
  26. /* Written by Paul Kunz, pfkeb@ebnextk.slac.stanford.edu              */
  27.  
  28. #import "Defaults.h"
  29.  
  30. #import <appkit/Application.h>
  31. #import <defaults/defaults.h>
  32. #import <appkit/Form.h>
  33. #import <appkit/Panel.h>
  34.  
  35. @implementation Defaults
  36.  
  37. - setTerminalPanel:anObject
  38. {
  39.     terminalPanel = anObject;
  40.     return self;
  41. }
  42.  
  43. - setTerminalForm:anObject
  44. {
  45.     terminalForm = anObject;
  46.     return self;
  47. }
  48.  
  49. - setShellPanel:anObject
  50. {
  51.     shellPanel = anObject;
  52.     return self;
  53. }
  54.  
  55. - setShellForm:anObject
  56. {
  57.     shellForm = anObject;
  58.     return self;
  59. }
  60.  
  61. - menuTerminal:sender
  62. {
  63.     static char *parameter[11] = {
  64.         "Lines", "Columns", "NXFixedPitchFont", "NXFixedPitchFontSize", "Console",
  65.         "Shell", "SourceDotLogin", "WinLocX", "WinLocY", "NXMenuX", "NXMenuY"
  66.     };
  67.     static char *terminalApp = "Terminal";
  68.     theApp = terminalApp;
  69.     thePanel = terminalPanel;
  70.     aForm = terminalForm;
  71.     theParms = parameter;
  72.     [self getDefaults];
  73.     return self;
  74. }
  75.  
  76. - menuShell:sender
  77. {
  78.     static char *parameter[9] = {
  79.         "HeightInChars", "WidthInChars", "NXFixedPitchFont", "NXFixedPitchFontSize",
  80.         "Console", "SourceDotLogin", "NXMenuX", "NXMenuY"
  81.     };
  82.     static char *shellApp = "Shell";
  83.     theApp = shellApp;
  84.     thePanel = shellPanel;
  85.     aForm = shellForm;
  86.     theParms = parameter;
  87.     [self getDefaults];
  88.     return self;
  89. }
  90.  
  91. - getDefaults
  92. {
  93.     const char *astring;
  94.     int             i, nrows, ncols;
  95.     [thePanel makeKeyAndOrderFront:self];
  96.     [aForm getNumRows:&nrows numCols: &ncols];
  97.     for (i = 0; i < nrows; i++) {
  98.         astring = NXReadDefault(theApp,theParms[i]);
  99.         [aForm setStringValue:astring at :i];
  100.     }
  101.     return self;
  102. }
  103.  
  104. - ok:sender
  105. {
  106.     const char *astring;
  107.     int             i, nrows, ncols;
  108.     [aForm getNumRows:&nrows numCols: &ncols];
  109.     for (i = 0; i < nrows; i++ ) {
  110.         astring = [aForm stringValueAt:i];
  111.         if ( astring == NULL )
  112.             continue;
  113.         if ( *astring != '\0' ) 
  114.             NXWriteDefault(theApp, theParms[i], astring);
  115.     }
  116.     [thePanel orderOut:self];
  117.     return self;
  118. }    
  119.  
  120. - cancel:sender
  121. {
  122.     [thePanel orderOut:self];
  123.     return self;
  124. }
  125.  
  126. @end
  127.